;(function($,_helper,_server){
    $(function(){
        $(document).on("pageInit", function(e, pageId, page) {
            $("#accountType").picker({
                toolbarTemplate: '<header class="bar bar-nav">\
                                      <button class="button button-link pull-right close-picker">确定</button>\
                                      <h1 class="title">请选择会员类型</h1>\
                                      </header>',
                cols: [
                    {
                        textAlign: 'center',
                        values: ['月度会员','年度会员']
                    }
                ],
                onClose:function(){
                    var accountTypeV = $("#accountType").val();
                    if(accountTypeV == "月度会员"){
                        $("#paymentCount").html("¥199");
                    }else if(accountTypeV == "年度会员"){
                        $("#paymentCount").html("¥1599");
                    }
                }
            });

            $("#sex").picker({
                toolbarTemplate: '<header class="bar bar-nav">\
                                      <button class="button button-link pull-right close-picker">确定</button>\
                                      <h1 class="title">请选择称谓</h1>\
                                      </header>',
                cols: [
                    {
                        textAlign: 'center',
                        values: ['男','女']
                    }
                ]
            });

            $("#city").cityPicker({
                toolbarTemplate: '<header class="bar bar-nav">\
                <button class="button button-link pull-right close-picker">确定</button>\
                  <h1 class="title">选择所在城市</h1>\
                 </header>'
            });
        });

        //支付
        $(".payment-btn").on("click",function(){
            var $accountType = $("#accountType");
            if(!$accountType.val()){
                $.alert('请选择会员类型！',function(){
                    $accountType.focus();
                });
                return false;
            }
            var $age = $("#age");
            if(!$age.val()){
                $.alert('请输入宝贝年龄！',function(){
                    $age.focus();
                });
                return false;
            }else if(!/^[1-9][0-9]*$/.test($age.val())){
                $.alert('宝贝的年龄输入不规范！',function(){
                    $age.focus();
                });
                return false;
            }
            var $sex = $("#sex");
            if(!$sex.val()){
                $.alert('请选择宝贝性别！',function(){
                    $sex.focus();
                });
                return false;
            }
            var $username = $("#username");
            if(!$username.val()){
                $.alert('请输入家长姓名！',function(){
                    $username.focus();
                });
                return false;
            }
            var $city = $("#city");
            if(!$city.val()){
                $.alert('请选择所在城市！',function(){
                    $city.focus();
                });
                return false;
            }

            $("#paymentForm").submit();
        });

        $.init();
    });
})(Zepto,_helper,_server);